package com.lovi;

import com.lovo.dto.UserDto;
import com.lovo.rb.entity.UserEntity;
import com.lovo.rb.service.UserServiceImpl;
import org.junit.jupiter.api.Test;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest(classes = com.lovo.RabbitMQ_S.class)
public class TRabbitMQ {
    @Autowired
    private RabbitTemplate rabbitTemplate;
    @Autowired
    private UserServiceImpl userService;
    @Test
    public void sendMQ(){
        UserDto userDto=new UserDto();
        userDto.setUserName("赵云");
        userDto.setAge(20);

        rabbitTemplate.convertAndSend("directExchangeOne","movie.ticket",userDto);
    }
    @Test
    public void sendMQTopic(){
        UserDto userDto=new UserDto();
        userDto.setUserName("赵云");
        userDto.setAge(20);

        rabbitTemplate.convertAndSend("topicExchangeTwo","order.ticket",userDto);
    }

    @Test
    public void sendMQFanout(){

    }

    @Test
    public void sendMQConfirm() throws InterruptedException {
        UserEntity user=new UserEntity();
        user.setScore(100);
        user.setUserName("赵云");
        user.setAge(20);


       userService.saveAndSendMQ(user);
    }
}
